#include "../properties.h"
#include "brakesloop.h"
#include <common/miscutils.h>

BrakesLoop::BrakesLoop()
	: ControlLoop(1000)		// init interval
{}

BrakesLoop::~BrakesLoop() {}
	
void BrakesLoop::init() {}

void BrakesLoop::calc() {
	PropAccessor p;
	float value = 0;
	
	switch (p().fcs.brakes.mode) {
	case Brakes_Value:  value = p().fcs.brakes.param1; break;
	case Brakes_RC:     value = -p().rc.elevator; break;
	case Brakes_Manual: value = -p().manual.elevator; break;
	default:			value = 0;
	}

	p().controls.brakes = limit(value, 0.0f, 1.0f);
}

